-
Notifications
You must be signed in to change notification settings - Fork 998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Starting on phase 1 misc beacon changes #1323
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djrtwo, All @inserts
look good to me. (I also tested it with the spec builder and it works as expected too.)
Other comments are minor changes mostly related to whitespace.
Co-Authored-By: Carl Beekhuizen <carl@ethereum.org>
2329171
to
c5acddc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changelogs
- Sorry for that I accidentally pushed the rebased branch. 🙈
- Enabled it in the CI and then the errors reveal...!
- Should merge Add shard state transition function #1326 before this one.
Co-Authored-By: Hsiao-Wei Wang <hwwang156@gmail.com>
Co-Authored-By: Hsiao-Wei Wang <hwwang156@gmail.com>
…d receipt proof Co-Authored-By: vbuterin <v@buterin.com>
""" | ||
Given a state and a list of validator indices, outputs the CompactCommittee representing them. | ||
""" | ||
validators = [state.validators[i] for i in committee] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validators = [state.validators[i] for i in committee] | |
assert len(committee) <= MAX_VALIDATORS_PER_COMMITTEE | |
validators = [state.validators[i] for i in committee] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? This function could theoretically be used for different kinds of committees; doesn't seem wise to put a maximum designed around a specific type of committee.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a safety check since the size of CompactCommittee
elements are set to maximum MAX_VALIDATORS_PER_COMMITTEE
:
class CompactCommittee(Container):
pubkeys: List[BLSPubkey, MAX_VALIDATORS_PER_COMMITTEE]
compact_validators: List[uint64, MAX_VALIDATORS_PER_COMMITTEE]
It leads to one more implicit config validity condition of that MAX_VALIDATORS_PER_COMMITTEE >= TARGET_PERSISTENT_COMMITTEE_SIZE
. (p.s. #407)
If we want to make this function could be used for different kinds of committees, how about refactoring this function into:
def pack_committee(state: BeaconState, committee: Sequence[ValidatorIndex]) -> Tuple[Sequence[BLSPubkey], Sequence[int]]:
validators = [state.validators[i] for i in committee]
compact_validators = [
pack_compact_validator(i, v.slashed, v.effective_balance // EFFECTIVE_BALANCE_INCREMENT)
for i, v in zip(committee, validators)
]
pubkeys = [v.pubkey for v in validators]
return pubkeys, compact_validators
def committee_to_compact_committee(state: BeaconState, committee: Sequence[ValidatorIndex]) -> CompactCommittee:
assert len(committee) <= MAX_VALIDATORS_PER_COMMITTEE
pubkeys, compact_validators = pack_committee(state, committee)
return CompactCommittee(pubkeys=pubkeys, compact_validators=compact_validators)
```python | ||
class CompactCommittee(Container): | ||
pubkeys: List[BLSPubkey, MAX_VALIDATORS_PER_COMMITTEE] | ||
compact_validators: List[uint64, MAX_VALIDATORS_PER_COMMITTEE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding a custom type CompactValidator: uint64
?
Edit: just realized that CompactValidator
and unpack_compact_validator
are defined in sync_protocol.md
. I'd say:
- Remove
unpack_compact_validator
from1_beacon-chain-misc.md
since it's not used here. - Move
CompactValidator
definition to1_beacon-chain-misc.md
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unpack_compact_validator from 1_beacon-chain-misc.md since it's not used here.
Where would it be put though? In the light client file that actually uses it? I can see how that's theoretically better in one way, but it has a big disadvantage, which is that pack and unpack are no longer beside each other. So I'd still favor putting both in the same file, to make it easier for readers to see that they are inverses.
Co-Authored-By: John Adler <adlerjohn@users.noreply.github.com>
Co-Authored-By: John Adler <adlerjohn@users.noreply.github.com>
Co-Authored-By: John Adler <adlerjohn@users.noreply.github.com>
Co-Authored-By: Hsiao-Wei Wang <hwwang156@gmail.com>
@vbuterin Is this ready for merge? |
I'd say so. My preference is generally to merge earlier for specs that are still in-progress; it makes it easier to propose further changes. Justin's upcoming PR may force a change to the internals of receipt processing but it won't be large. |
The PR is ready for review :) #1383 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving a green light in case it's blocking #1383 review. (receipts)
class ShardReceiptProof(Container): | ||
shard: Shard | ||
proof: List[Hash, PLACEHOLDER] | ||
receipt: List[ShardReceiptDelta, PLACEHOLDER] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like ShardReceiptDelta
is going away in #1383. Should we define the ShardReceiptDelta
container here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to merge this and handle the conflict after reviewing #1383. Thanks for pointing this out :)
No description provided.